package com.qf.service.impl;

import cn.hutool.crypto.SecureUtil;
import com.qf.dao.UserDao;
import com.qf.dao.impl.UserDaoImpl;
import com.qf.entity.User;
import com.qf.service.UserService;

/**
 * --- 天道酬勤 ---
 *
 * @author QiuShiju
 * @date 2024/6/26
 * @desc
 */
public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl( );
    @Override
    public User login(String username, String password) {
        // 处理数据,但是此次没有业务处理
        // 直接传递给dao层
        String s = SecureUtil.md5(password);
        User user = userDao.login(username, s);
        return user;
    }

    @Override
    public boolean regist(User user) {
        // 业务处理-对密码加密
        String password = user.getPassword( );
        String s = SecureUtil.md5(password);
        user.setPassword(s);

        boolean isok = userDao.regist(user);

        return isok;
    }

}
